<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c4jsf="http://java.sun.com/jsf/composite/component">

<ui:composition template="../template/layout.xhtml">

	<ui:define name="content">
			
		<div align="left">
			<h:panelGrid columns="2">
				<h:outputLabel value="Nome:">
					<br />
					<h:inputText value="#{categoryMB.entity.name}" styleClass="width150"/>
				</h:outputLabel>	
				<h:outputLabel value="Descrição:">
					<br />
					<h:inputText value="#{categoryMB.entity.description}" styleClass="width200"/>
				</h:outputLabel>				
			</h:panelGrid>
		</div>
		
		<div align="right">
			<p:commandButton actionListener="#{categoryMB.newEntity}" oncomplete="dlg.show();" value="Incluir Nova Categoria"/>
		</div>

		<h:form id="formList" prependId="false">
			<p:dataTable id="list" value="#{categoryMB.entityList}" var="entity" styleClass="width100POR" rowKey="#{entity.id}" selectionMode="single">
				<p:column headerText="#{bundle.label_code}" styleClass="width50">
					<h:outputText value="#{entity.id}" />
				</p:column>
				<p:column headerText="#{bundle.label_description}" styleClass="width100">
					<h:outputText value="#{entity.description}" />
				</p:column>
				<p:column styleClass="width40">
					<p:commandLink value="#{bundle.label_remove}" action="#{categoryMB.entitySelected}" process="@this" oncomplete="confirmationRemove.show();" title="#{bundle.label_remove}">
						<f:setPropertyActionListener value="#{entity}" target="#{categoryMB.entity}" />
					</p:commandLink>
				</p:column>				
			</p:dataTable>
			<c4jsf:paginator update="@form" paginator="#{categoryMB.paginator}"></c4jsf:paginator>
			<c4jsf:dialogRemove update="@form" managedBean="#{categoryMB}"></c4jsf:dialogRemove>
		</h:form>
		
			
		<p:dialog id="dialog" widgetVar="dlg" header="Title" width="400" 
					height="200" modal="true" resizable="false" showEffect="clip" hideEffect="clip">
			<h:form id="form">
				<div align="center">
					<h:panelGrid columns="1">
						<h:outputLabel value="Nome:">
							<br />
							<h:inputText value="#{categoryMB.entity.name}" styleClass="width370"/>
						</h:outputLabel>	
						<h:outputLabel value="Descrição:">
							<br />
							<h:inputText value="#{categoryMB.entity.description}" styleClass="width370"/>
						</h:outputLabel>				
					</h:panelGrid>
					<div>
						<p:commandButton value="salvar" actionListener="#{categoryMB.saveRefreshGrid}" onclick="dlg.hide()" update=":formList"/>
						<p:commandButton value="Cancelar" onclick="dlg.hide()"/>
					</div>
				</div>
			</h:form>
		</p:dialog>	
		
	</ui:define>
</ui:composition>
</html>